package com.medusa.aps.business.modules.security.mp.entity;

import cn.hutool.core.annotation.Alias;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.model.enums.MenuType;
import com.medusa.aps.business.model.enums.State;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
 * @author: xianhui.yu
 **/
@Data
@TableName("sys_menu")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class Menu extends BaseEntity<Menu> {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Schema(description = "主键")
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 上级菜单ID
     */
    @Schema(description = "上级菜单ID")
    private Long parentId;

    /**
     * 菜单名称
     */
    @Alias("菜单名称")
    @Schema(description = "菜单名称")
    @NotBlank(message = "菜单名称不能为空")
    private String title;

    /**
     * 路由地址
     */
    @Alias("路由地址/权限url")
    @Schema(description = "路由地址")
    private String path;

    /**
     * 显示顺序
     */
    @Alias("显示顺序")
    @Schema(description = "显示顺序")
    private Integer sortNo;
    /**
     * 状态
     */
    @Alias("状态")
    @Schema(description = "状态")
    private State state;

    /**
     * 类型 menu、button
     */
    @NotNull(message = "菜单类型不能为空")
    @Alias("菜单类型")
    @Schema(description = "类型 menu、button")
    private MenuType type;

    /**
     * 备注
     */
    @Alias("备注")
    @Schema(description = "备注")
    private String remarks;

    /**
     * 子菜单
     */
    @TableField(exist = false)
    @Schema(description = "子菜单")
    private List<Menu> menuChildren = new ArrayList<>();

    /**
     * 父菜单名称
     */
    @TableField(exist = false)
    @Alias("父级菜单")
    private String parentName;

    @Override
    public Serializable pkVal() {
        return this.id;
    }

}
